﻿

using Unity.Burst;
using Unity.Entities;
using Unity.Jobs;
using Unity.Transforms;

public partial struct RotatingCubeSystem:ISystem
{
    public void OnCreate(ref SystemState state)
    {
        state.RequireForUpdate<RotateSpeed>();
    }
    
    public void OnUpdate(ref SystemState state)
    {
        state.Enabled = false;
        return;
        
        var job = new RotatingCubeJob()
        {
            deltaTime = SystemAPI.Time.DeltaTime
        };

        state.Dependency = job.Schedule(state.Dependency);
    }
    
    [BurstCompile]
    [WithNone(typeof(Player))]
    public partial struct RotatingCubeJob:IJobEntity
    {
        public float deltaTime;
        public void Execute(ref LocalTransform localTransform, in RotateSpeed rotateSpeed)
        {
            localTransform = localTransform.RotateY(rotateSpeed.Value * deltaTime);
        }
    }
}